<template>
  <div>
    <!--
    <Search :search="search" :reset="reset">
      <template v-slot:body>
        <el-form-item label="名称">
          <el-input v-model="query.name" clearable />
        </el-form-item>
      </template>
    </Search>
    <div class="table-default">
      <Operate :show="open" />
      <el-table :data="tableData" class="mt-3" v-loading="loading" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="id" label="ID" />
        <el-table-column prop="name" label="名称" />
        <el-table-column prop="created_at" label="创建时间" />
        <el-table-column label="操作">
          <template #default="scope">
            <Update @click="open(scope.row.id)" />
            <Destroy @click="destroy(api, scope.row.id)" />
          </template>
        </el-table-column>
      </el-table>
      <div class="flex justify-between">
        <div class="pt-4">
          <Destroy text="批量删除" @click="multiDel" />
        </div>
        <Paginate />
      </div>
    </div>

    <Dialog v-model="visible" :title="title" destroy-on-close>
      <Create @close="close(reset)" :primary="id" :api="api" />
    </Dialog>
    -->
    <catch-table
      :columns="columns"
      :search-form="[
        {
          type: 'input',
          name: 'name',
          label: '名称'
        }
      ]"
      :api="api"
    >
      <!-- dialog -->
      <template #dialog="row">
        <Create :primary="row?.id" :api="api" />
      </template>
    </catch-table>
  </div>
</template>

<script lang="ts" setup>
import Create from './create.vue'

const api = 'cms/tag'

const columns = [
  {
    type: 'selection'
  },
  {
    prop: 'id',
    label: 'ID'
  },
  {
    prop: 'name',
    label: '名称'
  },
  {
    prop: 'created_at',
    label: '创建时间'
  },
  {
    type: 'operate',
    label: '操作'
  }
]
</script>
